package com.zhugy.comparecode.asm;

import com.zhugy.comparecode.BaseCodeLine;
import com.zhugy.comparecode.CodeLine;
import com.zhugy.comparecode.CompareResult;
import com.zhugy.comparecode.util.CommonUtils;

public class LabelLine extends BaseCodeLine implements CodeLine {
	
	String labelName;
	String content;

	public LabelLine(int index, String labelName, String content) {
		super();
		this.index = index;
		this.labelName = labelName;
		this.content = content;
	}

	public String getLabelName() {
		return labelName;
	}

	public void setLabelName(String labelName) {
		this.labelName = labelName;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public CompareResult compareTo(CodeLine l) {
		if (!(l instanceof LabelLine)) {
			return CompareResult.fail("代码类型不一样");
		}
		LabelLine a = (LabelLine) l;
		if (this.labelName == null) {
			throw new RuntimeException("标签名字不能为空");
		}
		if (!labelName.equalsIgnoreCase(a.getLabelName())) {
			return CompareResult.fail("命令不一样，" + this.labelName + " VS " + a.getLabelName());
		}
		String c1 = this.content;
		String c2 = a.getContent();
		return CommonUtils.compareContent(c1, c2);
	}

}
